package Features;
import core.Document;


public class FeatureVizinhos extends Feature{

	public FeatureVizinhos(String argumento) {
		activo = argumento.toLowerCase().contains("vizinhos");
	}
	
	public void extract(Document doc){
		if(activo==false) 
			return;
		
		String[] completeFeatures = new String[doc.sentenceList.length];
		for(int i=0; i<doc.sentenceList.length; i++){
			String featuresFraseCima;
			String featuresFraseBaixo;
			if(i==0){
				featuresFraseCima=new String(doc.sentenceList[i].featureVector);
				featuresFraseCima=featuresFraseCima.replaceAll("[0-9]+", "0");
			}else{
				featuresFraseCima=new String(doc.sentenceList[i-1].featureVector);
			}
			
			if(i==doc.sentenceList.length-1){
				featuresFraseBaixo=new String(doc.sentenceList[i].featureVector);
				featuresFraseBaixo=featuresFraseBaixo.replaceAll("[0-9]+", "0");
			}else{
				featuresFraseBaixo=new String(doc.sentenceList[i+1].featureVector);
			}
			completeFeatures[i] = new String(doc.sentenceList[i].featureVector+featuresFraseCima+featuresFraseBaixo);
		}
		
		for(int i=0; i<doc.sentenceList.length; i++){
			doc.sentenceList[i].featureVector=completeFeatures[i];
		}
	}
	
}
